package com.chat.datea.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.chat.datea.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 周橹 on 15/10/23.
 */
public class SingerListViewAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context mContext;

    // 为条目提供数据
    public static List<String> singer = new ArrayList<>();

    public SingerListViewAdapter(Context context) {
        this.mContext = context;
        inflater = LayoutInflater.from(this.mContext);

        singer.add(mContext.getResources().getString(R.string.chinese_singer_male));
        singer.add(mContext.getResources().getString(R.string.chinese_singer_female));
        singer.add(mContext.getResources().getString(R.string.chinese_mix));
        singer.add(mContext.getResources().getString(R.string.western_singer_male));
        singer.add(mContext.getResources().getString(R.string.western_singer_female));
        singer.add(mContext.getResources().getString(R.string.western_mix));
        singer.add(mContext.getResources().getString(R.string.korea_singer_male));
        singer.add(mContext.getResources().getString(R.string.korea_singer_female));
        singer.add(mContext.getResources().getString(R.string.korea_mix));
        singer.add(mContext.getResources().getString(R.string.japan_singer_male));
        singer.add(mContext.getResources().getString(R.string.japan_singer_female));
        singer.add(mContext.getResources().getString(R.string.japan_mix));
        singer.add(mContext.getResources().getString(R.string.other_singer));
    }


    @Override
    public int getCount() {
        return 13; // 条目数量
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.singer_fragment_listview_item, null);
            holder.textView = (TextView) convertView.findViewById(R.id.singer_classify);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.textView.setText(singer.get(position));

            return convertView;
    }


    private class ViewHolder {
        TextView textView;
    }
}

